<%@page language="java" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@taglib uri="TowkerTagLib" prefix="rbac"%>
<%@include file="/commons/include/html_doctype.html"%>
<html>
<head>
	<title>添加</title>
	<%@include file="/commons/include/add.jsp" %>
    <link rel="stylesheet" href="${ctx}/js/jquery/ui/css/jquery-ui.css" />
    <script src="${ctx}/js/jquery/ui/jquery-ui.js"></script>
    <script src="${ctx}/js/jquery/ui/jquery.ui.combobox.js"></script>
	<script type="text/javascript">
$(function(){
	
	jQuery("#dataForm").validate(
	{
		rules: {
			custom_code:{
				required: true
			},
			region_id:{
				required:true
			},
			custom_name:{
				required:true
			},
			custom_addr:{
				required:true
			},
			discount:{
				required:true
			},
			linkman1:{
				required:true
			},
			phone1:{
				required:true
			}
			
		},
		messages: {
			custom_code:{
				required: "请填写客户代码"
			},
			region_id:{
				required:"请选择所属地区"
			},
			custom_name:{
				required:"请填写客户名称"
			},
			custom_addr:{
				required:"请填写客户地址"
			},
			discount:{
				required:"请预设客户销售价标"
			},
			linkman1:{
				required:"请填写联系人"
			},
			phone1:{
				required:"请填写电话"
			}
		},
		submitHandler:function(form)
		{
			if($("#co_code").val() == "")
				$("#co_code").val($('#a_co_code').val());
			jQuery.ajax({
				url : ctx + '/manage/basicData/checkExistsCustomCode.htm',
				type : "POST",
				data : {id:0,custom_code:$('#custom_code').val()},
				dataType : "json",
				success : function(d) {
				if(!d.result)
					jQuery(form).ajaxSubmit(_options);
				else
					alert('品种代码有重复!');
				},error:function(){
				   alert('后台验证品种代码出错');
				}
			});	
		}
	});
	if($("#co_code").val() != "") {
		$("#a_co_code").hide();
		$("#s_co_code").show();
	} else {
		$("#a_co_code").combobox();
		$("#s_co_code").hide();
	}
});
_callback = function() {
	location.href = ctx + "/manage/basicData/getCustoms.htm";
}
validCallBack = function()
{
	//添加页面自定义校验

	return true;
};
	</script>
</head>
<body>
<table border="0" cellspacing="0" cellpadding="0" class="listLogo">
	<tr>
		<td class="title">销售客户添加</td>
		<td>
			<div class="menuTool">
				<a class="save" id="dataFormSave" href="#">保存</a>
				<a class="back" href="getCustoms.htm">返回</a>
			</div>
		</td>
	</tr>
</table>
<div class="line"></div>
<form id="dataForm" method="post" action="addCustoms2.htm">
<table border="0" cellspacing="1" cellpadding="0" class="listTable">
	<tr>
		<td class="form_title">客户代码：</td>
		<td class="form_input"><input type="text" id="custom_code" name="custom_code" value=""  /></td>
		
		<td class="form_title">所属地区：</td>
		<td class="form_input">
		<select id="region_id" name="region_id">
				<option value="" >请选择</option>
				 <c:forEach items="${regionsList}" var="d" varStatus="status">
					<option value="${d.id}">${d.region_code}[${d.region_name}]</option>
				</c:forEach>
		</select>
		</td>
		<td class="form_title">客户名称：</td>
	  <td class="form_input"><input type="text" id="custom_name" name="custom_name" value="" /></td>
	</tr>
	<tr>
	    <td class="form_title">所属公司：</td>
	    <td class="form_input">
        <select id="a_co_code" name="a_co_code">
				 <c:forEach items="${companiesList}" var="d" varStatus="status">
					<option value="${d.co_code}" <c:if test="${d.co_code==po.co_code}">selected="selected"</c:if> >${d.co_name}[${d.co_code}]</option>
				</c:forEach>
		</select>
        <span id="s_co_code">${co_name}${co_code}</span>
        </td>
	    
		<td class="form_title">邮政编码：</td>
		<td class="form_input"><input type="text" id="zip" name="zip" value="" /></td>
		
		<td class="form_title">客户地址：</td>
		<td class="form_input"><input type="text" id="custom_addr" name="custom_addr" value="" /></td>
	</tr>
	<tr>
		<td class="form_title">联系人1：</td>
		<td class="form_input"><input type="text" id="linkman1" name="linkman1" value="" /></td>
		
		<td class="form_title">预设客户销售价标：</td>
		<td class="form_input"><input type="text" id="discount" name="discount" value="" /></td>
		
		<td class="form_title">电话1：</td>
		<td class="form_input"><input type="text" id="phone1" name="phone1" value="" /></td>
	</tr>
	<tr>
	    <td class="form_title">联系人2：</td>
		<td class="form_input"><input type="text" id="linkman2" name="linkman2" value="" /></td>
	
		<td class="form_title">电话3：</td>
		<td class="form_input"><input type="text" id="phone3" name="phone3" value="" /></td>
		
		<td class="form_title">电话2：</td>
		<td class="form_input"><input type="text" id="phone2" name="phone2" value="" /></td>
	</tr>
	<tr>
		<td class="form_title">电子邮件：</td>
		<td class="form_input"><input type="text" id="email" name="email" value="" /></td>
		
		<td class="form_title">传真：</td>
		<td class="form_input"><input type="text" id="fax" name="fax" value="" /></td>
		
		<td class="form_title">客户帐号：</td>
		<td class="form_input"><input type="text" id="account" name="account" value="" /></td>
	</tr>
	<tr>
		<td class="form_title">客户税号：</td>
		<td class="form_input"><input type="text" id="tax_id" name="tax_id" value="" /></td>
		<td class="form_title"></td>
		<td class="form_input"></td>
		<td class="form_title"></td>
		<td class="form_input"></td>
	</tr>
	<tr>
		<td class="form_title">备注：</td>
		<td colspan="5" class="form_input"><textarea name="remark" style="width:99%" rows="2" id="remark"></textarea></td>
	</tr>
</table>
<input type="hidden" name="co_code" id="co_code" value="${co_code}" />
</form>
</body>
</html>
